package com.woniu.serverdriveruser.controller;

import com.woniu.serverdriveruser.service.DriverCarBindingService;
import com.woniu.internalcommon.dto.DriverCarBindingRelationship;
import com.woniu.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bind")
public class DriverCarBindingController {
    @Autowired
    private DriverCarBindingService driverCarBindingService;

    /**
     * 根据司机id和车辆id查询绑定关系
     * @param driverCarBindingRelationship
     * @return
     */
    @GetMapping("/selectBinding")
    public ResponseResult selectBinding(DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingService.getDriverCarBindingRelationships(driverCarBindingRelationship);
    }

    /**
     * 添加绑定关系
     * @param driverCarBindingRelationship
     */
    @PostMapping("/binding")
    public ResponseResult binding(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){

        return driverCarBindingService.binding(driverCarBindingRelationship);
    }

    /**
     * 解绑关系
     * @param driverCarBindingRelationship
     */
    @DeleteMapping("/unBinding")
    public ResponseResult unBinding(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingService.unBinding(driverCarBindingRelationship);
    }
}
